<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of VMT_CompMeanXS</title>
  <meta name="keywords" content="VMT_CompMeanXS">
  <meta name="description" content="Computes the mean cross section data from individual transects">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- menu.html VMT_4.0_dev -->
<h1>VMT_CompMeanXS
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Computes the mean cross section data from individual transects</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [A,V,log_text] = VMT_CompMeanXS(z,A,V) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Computes the mean cross section data from individual transects
 that have been previously mapped to a common grid.

 (adapted from code by J. Czuba)

 P.R. Jackson, USGS, 12-9-08</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="VMT_ProcessTransects.html" class="code" title="function [A,V,log_text] = VMT_ProcessTransects(z,A,setends)">VMT_ProcessTransects</a>	Driver program to process multiple transects at a single cross-section</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [A,V,log_text] = VMT_CompMeanXS(z,A,V)</a>
0002 <span class="comment">% Computes the mean cross section data from individual transects</span>
0003 <span class="comment">% that have been previously mapped to a common grid.</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% (adapted from code by J. Czuba)</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% P.R. Jackson, USGS, 12-9-08</span>
0008 
0009 
0010 
0011 <span class="comment">%% Average mapped mean cross-sections from individual transects together</span>
0012 
0013 <span class="comment">% Averaging for backscatter is only computed for Rio Grande probes</span>
0014 <span class="comment">% Procedure for SonTek probes is different</span>
0015 
0016 <span class="keyword">switch</span> V.probeType
0017     <span class="comment">% Assign mapped uniform grid vectors to the same array for averaging</span>
0018     <span class="keyword">case</span> <span class="string">'RG'</span>
0019         <span class="keyword">for</span> zi = 1 : z
0020             
0021             Back(:,:,zi) = A(zi).Comp.mcsBack(:,:);
0022             Dir(:,:,zi) = A(zi).Comp.mcsDir(:,:);
0023             Mag(:,:,zi) = A(zi).Comp.mcsMag(:,:);
0024             East(:,:,zi) = A(zi).Comp.mcsEast(:,:);
0025             North(:,:,zi) = A(zi).Comp.mcsNorth(:,:);
0026             Vert(:,:,zi) = A(zi).Comp.mcsVert(:,:);
0027             Bed(:,:,zi) = A(zi).Comp.mcsBed(:,:);
0028             
0029         <span class="keyword">end</span>
0030         
0031         numavg = nansum(~isnan(Mag),3);
0032         numavg(numavg==0) = NaN;
0033         enscnt = nanmean(numavg,1);
0034         [I,J] = ind2sub(size(enscnt),find(enscnt&gt;=1));  <span class="comment">%Changed to &gt;= 1 PRJ 12-10-08  (uses data even if only one measurement)</span>
0035         
0036         
0037         Backone= Back;
0038         Backone(~isnan(Back))=1;
0039         V.countBack = nansum(Backone,3);
0040         V.countBack(V.countBack==0)=NaN;
0041         V.mcsBack = nanmean(Back,3);
0042         
0043         
0044         Magone = Mag;
0045         Vertone = Vert;
0046         Bedone = Bed;
0047         
0048         
0049         Magone(~isnan(Mag))=1;
0050         Vertone(~isnan(Vert))=1;
0051         Bedone(~isnan(Bed))=1;
0052         
0053         
0054         V.countMag = nansum(Magone,3);
0055         V.countVert = nansum(Vertone,3);
0056         V.countBed = nansum(Bedone,3);
0057         
0058         V.countMag(V.countMag==0)=NaN;
0059         V.countVert(V.countVert==0)=NaN;
0060         V.countBed(V.countBed==0)=NaN;
0061         
0062         <span class="comment">% Average mapped mean cross-sections from individual transects together</span>
0063         
0064         <span class="comment">%V.mcsDir = nanmean(Dir,3);  % Will not average correctly in all cases due to 0-360</span>
0065         <span class="comment">%wrapping (PRJ, 9-29-10)</span>
0066         <span class="comment">%V.mcsMag = nanmean(Mag,3);  %Mag recomputed from north, east, up components(PRJ, 3-21-11)</span>
0067         V.mcsEast = nanmean(East,3);
0068         V.mcsNorth = nanmean(North,3);
0069         V.mcsVert = nanmean(Vert,3);
0070     
0071     <span class="comment">% Put all of the Sontek data in one place, then interpolate values at</span>
0072     <span class="comment">% the MCS grid</span>
0073     <span class="keyword">case</span> <span class="string">'M9'</span>
0074         
0075         x       = []; 
0076         y       = []; 
0077         East    = [];
0078         North   = [];
0079         Vert    = [];
0080         <span class="keyword">for</span> zi = 1: z
0081             
0082             Dir(:,:,zi) = A(zi).Comp.mcsDir(:,:);
0083             Bed(:,:,zi) = A(zi).Comp.mcsBed(:,:);
0084             
0085             xx    = meshgrid(A(zi).Comp.dl,A(zi).Wat.binDepth(:,1));
0086             x     = [x; xx(:)];
0087             y     = [y; A(zi).Wat.binDepth(:)];
0088             East  = [East;  A(zi).Wat.vEast(:)];
0089             North = [North; A(zi).Wat.vNorth(:)];
0090             Vert  = [Vert;  A(zi).Wat.vVert(:)];
0091         <span class="keyword">end</span>
0092 
0093         <span class="comment">% FIXME: I call griddate 3 times. Need to rewrite to create 1</span>
0094         <span class="comment">% delauney tri, and replace the V data.</span>
0095         V.mcsEast  = griddata(x,y,East,V.mcsDist,V.mcsDepth);
0096         V.mcsNorth = griddata(x,y,North,V.mcsDist,V.mcsDepth);
0097         V.mcsVert  = griddata(x,y,Vert,V.mcsDist,V.mcsDepth);
0098 
0099 <span class="keyword">end</span> <span class="comment">% switch Probe type</span>
0100 
0101         <span class="comment">%Average Magnitude</span>
0102         V.mcsMag = sqrt(V.mcsEast.^2 + V.mcsNorth.^2 + V.mcsVert.^2);
0103         
0104         <span class="comment">%Average the flow direction</span>
0105         V.mcsDir = ari2geodeg((atan2(V.mcsNorth, V.mcsEast))*180/pi);
0106         <span class="comment">% V.mcsDir = 90 - (atan2(V.mcsNorth, V.mcsEast))*180/pi; %Compute the atan from the velocity componentes, convert to radians, and rotate to north axis</span>
0107         <span class="comment">% qindx = find(V.mcsDir &lt; 0);</span>
0108         <span class="comment">%     if ~isempty(qindx)</span>
0109         <span class="comment">%         V.mcsDir(qindx) = V.mcsDir(qindx) + 360;  %Must add 360 deg to Quadrant 4 values as they are negative angles from the +y axis</span>
0110         <span class="comment">%     end</span>
0111         
0112         V.mcsBed = nanmean(Bed,3);
0113         
0114         <span class="comment">%Compute the Bed Elevation in meters (Takes the mean value of the entered</span>
0115         <span class="comment">%WSE timeseries if file loaded)</span>
0116         <span class="comment">%disp(['Assigned Water Surface Elevation (WSE; in meters) = ' num2str(mean(A(1).wse))])</span>
0117         log_text = [<span class="string">'      WSE in meters) = '</span> num2str(mean(A(1).wse))];
0118         V.mcsBedElev = mean(A(1).wse) - V.mcsBed;
0119         
0120 
0121 
0122 <span class="keyword">return</span>
0123 
0124 <span class="comment">% Remove values (Omitted 11/23/10, PRJ)</span>
0125 <span class="comment">% Clean up</span>
0126 <span class="comment">% switch A(1).probeType</span>
0127 <span class="comment">%     case 'RG'</span>
0128 <span class="comment">%         V.mcsBack(:,1:J(1)-1)=NaN;</span>
0129 <span class="comment">%         V.mcsBack(:,J(end)+1:end)=NaN;</span>
0130 <span class="comment">%         V.countBack(:,1:J(1)-1)=NaN;</span>
0131 <span class="comment">%         V.countBack(:,J(end)+1:end)=NaN;</span>
0132 <span class="comment">% end</span>
0133 <span class="comment">%</span>
0134 <span class="comment">% V.mcsDir(:,1:J(1)-1)=NaN;</span>
0135 <span class="comment">% V.mcsDir(:,J(end)+1:end)=NaN;</span>
0136 <span class="comment">% V.mcsMag(:,1:J(1)-1)=NaN;</span>
0137 <span class="comment">% V.mcsMag(:,J(end)+1:end)=NaN;</span>
0138 <span class="comment">% V.mcsEast(:,1:J(1)-1)=NaN;</span>
0139 <span class="comment">% V.mcsEast(:,J(end)+1:end)=NaN;</span>
0140 <span class="comment">% V.mcsNorth(:,1:J(1)-1)=NaN;</span>
0141 <span class="comment">% V.mcsNorth(:,J(end)+1:end)=NaN;</span>
0142 <span class="comment">% V.mcsVert(:,1:J(1)-1)=NaN;</span>
0143 <span class="comment">% V.mcsVert(:,J(end)+1:end)=NaN;</span>
0144 <span class="comment">% V.mcsBed(:,1:J(1)-1)=NaN;</span>
0145 <span class="comment">% V.mcsBed(:,J(end)+1:end)=NaN;</span>
0146 <span class="comment">% V.countMag(:,1:J(1)-1)=NaN;</span>
0147 <span class="comment">% V.countVert(:,1:J(1)-1)=NaN;</span>
0148 <span class="comment">% V.countBed(:,1:J(1)-1)=NaN;</span>
0149 <span class="comment">% V.countMag(:,J(end)+1:end)=NaN;</span>
0150 <span class="comment">% V.countVert(:,J(end)+1:end)=NaN;</span>
0151 <span class="comment">% V.countBed(:,J(end)+1:end)=NaN;</span>
0152 
0153</pre></div>
<hr><address>Generated on Thu 21-Mar-2013 09:32:01 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>